<script>
import Vue from 'vue'
import store from '@/store'
import cache from '@/common/cache'
import { machine } from '@/api/index'

export default {
    onLaunch:  function() {
        this.initColorUi();
        this.initUser()
    },
    onShow: function() {

    },
    onHide: function() {
    },
    methods:{
        async initUser(){
            //自动登录
            if(this.$tools.getToken()){
                this.$user.userInfo()
            }
        },
        initColorUi(){
            uni.getSystemInfo({
                success: function(e) {

                    console.log('系统信息返回的结果是')
                    console.log(e)
                    // #ifndef MP
                    Vue.prototype.StatusBar = e.statusBarHeight;

                    if (e.platform == 'android') {
                        Vue.prototype.CustomBar = e.statusBarHeight + 50;
                    } else {
                        Vue.prototype.CustomBar = e.statusBarHeight + 45;
                    };
                    // #endif

                    // #ifdef MP-WEIXIN || MP-QQ
                    Vue.prototype.StatusBar = e.statusBarHeight;
                    let capsule = wx.getMenuButtonBoundingClientRect();
                    if (capsule) {
                        console.log('capsule')
                        console.log(capsule)
                        Vue.prototype.Custom = capsule;
                        // Vue.prototype.capsuleSafe = uni.upx2px(750) - capsule.left + uni.upx2px(750) - capsule.right;
                        Vue.prototype.CustomBar = capsule.bottom + capsule.top - e.statusBarHeight;
                    } else {
                        Vue.prototype.CustomBar = e.statusBarHeight + 50;
                    }
                    // #endif


                    // #ifdef MP-ALIPAY
                    Vue.prototype.StatusBar = e.statusBarHeight;
                    Vue.prototype.CustomBar = e.statusBarHeight + e.titleBarHeight;
                    // #endif

                    Vue.prototype.$systemInfo   = e;
                    Vue.prototype.$windowWidth  = e.windowWidth
                    Vue.prototype.$windowHeight = e.windowHeight
                    Vue.prototype.$statusBarHeight = e.statusBarHeight

                   console.log("===========")
                    console.log('状态高度statusBarHeight'+e.statusBarHeight)
                    console.log('客户栏高度CustomBar'+Vue.prototype.CustomBar)
                }
            })

        }
    }
}
</script>
<style lang="scss">
@import "static/iconfont/iconfont.css";
@import "static/iconfont/iconfont_nan.css";
@import "static/colorui/main.css";
@import "static/colorui/icon.css";
@import "static/app.scss";
</style>
